﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common.ConsoleSysMessages;

/// <summary>
/// 登录服务器控制台命令集合
/// </summary>
namespace LoginServer.Command
{
    public class CLoginCommand
    {
        [Common.ConsoleSysMessages.Command("StartOver","开启服务器..")]
        public bool StartOver(string [] Command)
        {
            // 开启参数不能小于1
            if(Command.Length < 1)
            {
                return false;
            }

            try
            {
                LoginServer.Server.LoginServer.Instance = new Server.LoginServer(int.Parse(Command[1]));
            }catch(Exception e)
            {
                System.Console.WriteLine("服务端开启失败!{0}", e);
            }

            return true;
        }


        [Common.ConsoleSysMessages.Command("CloseServer","关闭服务器 - 使用方法: CloseServer")]
        public bool CloseServer(string[] Command)
        {
            try
            {
                LoginServer.Server.LoginServer.Instance.CloseServer();
            }
            catch (Exception e)
            {
                System.Console.WriteLine("关闭服务器失败:{0}", e);
            }

            return true;
        }


    }
}
